package com.zz.springboot.holder;

import com.zz.springboot.dto.MaxMoneyParamDto;
import org.apache.shiro.SecurityUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 用于全局缓存
 */
public class ParamDataHolder {

    private static Map<String, MaxMoneyParamDto> maxMoneyParamMap = new HashMap<>();

    public static void setMaxMoneyParamMap(String username, MaxMoneyParamDto maxMoneyParam) {
        maxMoneyParamMap.put(username, maxMoneyParam);
    }

    public static void setMaxMoneyParamMap(String username, Integer aomenMaxValue, Integer xianggangMaxValue) {
        String operator = (String) SecurityUtils.getSubject().getSession().getAttribute("username");
        maxMoneyParamMap.put(username, new MaxMoneyParamDto(aomenMaxValue, xianggangMaxValue, operator));
    }

    public static Map<String, MaxMoneyParamDto> getMaxMoneyParamMap() {
        return maxMoneyParamMap;
    }

    public static MaxMoneyParamDto getMaxMoneyParam(String username) {
        return maxMoneyParamMap.get(username);
    }
}
